vcTriangleSet

vcTriangleSet is a geometry set used for creating and storing a collection of triangles and tessellated surface data.

See in: Overview

Module: vcGeometry

Parent: vcGeometrySet

Children -

Referenced by: -

Properties

Learn how to use properties here. The properties are also inherited from the parent class.

NameTypeAccessDescription
CreaseAngleRealRGets the angle tolerance for triangle
See more
edge shading in which edge angles less than tolerance are rendered as smooth surfaces during light calculations.
PointCountIntegerRGets the total number of points in set.
Pointslist[vcVector]RWGets or sets a positions in the form of an ordered list used for generating triangles of set.
See more
In order to generate triangles, position values should have a known index and be in XYZ order. For example, [123.0,45.0,4.5,15.0,45.0,90.0] would define the position of two points which are aligned on Y-axis. If the number of entries is not enough for all points in set, those points will be deleted from set as a clean up operation. If number is more than is needed for points, additional points are created in set.
TextureCoordinateslist[Real]RWGets or sets list of texture coordinates for points in set.
See more
If the number of entries is not enough for all points in set, those points will be deleted from set as a clean up operation. If number is more than is needed for points, additional points are created in set.
TopologyvcTopologyRGets the container of topology data for points in set.
TriangleCountIntegerRGets the total number of triangles in set.
TriangleIndiceslist[Integer]RWGets or sets the triangle indices of a set, which is an ordered list of vertex indices for each triangle.
UseDynamicTextureCoordinatesBooleanRWGets or sets the value that controls weather texture coordinates of set can be updated during simulation.
UseTextureCoordinatesBooleanRWGets or sets the use of texture coordinates in set.

Methods

Learn how to use methods here. The methods are also inherited from the parent class.

NameReturn TypeParametersDescription
addPointIntegervcVector pointAdds a point to set, and then returns index of point in set.
See more
Parameters:
vector (vcVector): Position for the point.

Returns:
index (int): Index for the point.
addPointIntegerReal x,
Real y,
Real z
Adds a point to set, and then returns index of point in set.
See more
Parameters:
x (float): x coordinate for the vector.
y (float): y coordinate for the vector.
z (float): z coordinate for the vector.

Returns:
index (int): Index for the point.
addTriangleIntegerInteger pointIndex1,
Integer pointIndex2,
Integer pointIndex3
Adds a triangle to set, and then returns new triangle count of set. See Example: Create sphere with triangle sets for more information.
See more
Parameters:
pointIndex1 (int): Vertex index for the first vertex.
pointIndex2 (int): Vertex index for the second vertex.
pointIndex3 (int): Vertex index for the third vertex.

Exceptions:
IndexError: Index out of bounds.

Returns:
triangleIndex (int): Index for the triangle.
collapsePointNoneInteger indexPoint1,
Integer indexPoint2
Collapses a point at a given index into another point at a given index in set, thereby updating triangles referencing first point to now reference second point.
See more
Generally, this is used to clean up redundant vertices, reduce data count or simplify geometry.

Parameters:
indexPoint1 (int): Index of the first point.
indexPoint2 (int): Index of the second point.

Exceptions:
IndexError: Index out of bounds.
convexHullvcTriangleSetBoolean valueCreates a convex hull from geometry of set.
See more
Parameters:
value (bool): If true, returns a new triangle set containing the resultant geometry. Otherwise, modifies the current geometry of set and returns the same set.

Returns:
vcTriangleSet: The convex hull set.
decimateRealReal quality,
Real maxError
Simplifies triangles of set by merging points within a given maxError tolerance until a given quality level is achieved or tolerance is exceeded.
See more
Parameters:
quality (float): Decimation quality percentage. Value between [0, 100]. A quality of N% means that (100 - N)% reduction will be done on the mesh.
maxError (float): Decimation tolerance.

Returns:
float: Reduction Percentage. Percentage of triangles removed.
decomposeNoneNoneRegroups triangles in set into different sets based on the connection of each triangle to one another.
deleteTriangleNoneInteger triangleIndexDeletes a triangle at a given index in set.
See more
You should call the update() method after deleting one or more triangles from set.

Parameters:
triangleIndex (int): Index of the triangle to delete.

Exceptions:
IndexError: Index out of bounds.
getPointvcVectorInteger pointIndexReturns the position vector of point at a given index in set.
See more
Parameters:
pointIndex (int): Index for the point.

Exceptions:
IndexError: Index out of bounds.

Returns:
vcVector: Position vector.
getPointIndicesWithinlist[Integer]vcVector position,
Real sideLength
Returns a list of indices for points in set within an area defined by a given position and sideLength.
See more
Parameters:
position (vcVector): Reference point position.
sideLength (float): Search area side length.

Exceptions:
LicenseError: No license for Robotics API.

Returns:
list[int]: list of integer point indices.
getPointIndicesWithinlist[Integer]vcVector position,
Real sideLength,
vcVector normal
Returns a list of indices for points in set within an area defined by a given position and sideLength.
A normal argument can be given to filter points with the same surface normal.
See more
Parameters:
position (vcVector): reference point position.
sideLength (float): Search area side length.
normal (vcVector): Search area normal vector.

Exceptions:
LicenseError: No license for Robotics API.

Returns:
list[int]: list of integer point indices.
getPointNormalslist[vcVector]List[Integer] indices,
Optional Keyword[convert = vcMatrix]
Returns a list of surface normal vectors for points at a given list of indices in set.
See more
A convert argument can be used to transform each vector by a given matrix.

Parameters:
indices (list[int]): List of integer indices.
Optional: convert (vcMatrix): Matrix for converting normals.

Exceptions:
IndexError: Index out of bounds.
LicenseError: No license for Robotics API.

Returns:
list[vcVector]: List of vcVector normals.
getPointPositionslist[vcVector]List[Integer] indices,
Optional Keyword[convert = vcMatrix]
Returns a list of position vectors for points at a given list of indices in set.
See more
A convert argument can be used to transform each vector by a given matrix.

Parameters:
indices (list[int]): List of integer indices.
Optional: convert (vcMatrix): Matrix for converting positions.

Exceptions:
IndexError: Index out of bounds.
LicenseError: No license for Robotics API.

Returns:
list[vcVector]: List of vcVector positions.
getTextureCoordinatetuple[Real, Real]Integer indexGets an ordered pair of UV coordinates for the point at the given index.
See more
Parameters:
index (int): Texture coordinate index.

Exceptions:
IndexError: Index out of bounds.

Returns:
tuple[float, float]: 2-tuple (float u, float v) texture coordinate.
getTextureCoordinateslist[tuple[Real, Real]]List[Integer] indicesGets a list containing an ordered pair of UV coordinates for points at given indices in set.
See more
Parameters:
indices (list): List of integer indices

Exceptions:
IndexError: Index out of bounds.
LicenseError: No license for Robotics API.

Returns:
list[tuple[float, float]]: List of 2-tuple (float u, float v) texture coordinates.
getTriangletuple[Integer, Integer, Integer]Integer triangleIndexReturns the indices of vertices for a triangle at a given index in set.
See more
Parameters:
triangleIndex (int): Index for the triangle.

Exceptions:
IndexError: Index out of bounds.

Returns:
tuple[int, int, int]: (int pointIndex1, int pointIndex2, int pointIndex3)
getTriangleEdgeNeighbortuple[Integer, Integer] OR NoneInteger index,
Integer vertex
Returns the index of a triangle neighboring another triangle at a given index and vertex in set.
See more
The returned value is an ordered pair identifying neighboring triangle and shared vertex in set.

Parameters:
index (int): Triangle index.
vertex (int): Vertex number. Should be either 0, 1 or 2.

Exceptions:
IndexError: Index out of bounds.

Returns:
tuple[int, int]: (int triangleIndex, int vertexIndex)
getTriangleEdgeTypevcEdgeTypeInteger index,
Integer vertex
Returns the type of edge for a triangle at a given index and vertex in set.
See more
Parameters:
index (int): Triangle index.
vertex (int): Vertex number. Should be either 0, 1 or 2.

Exceptions:
IndexError: Index out of bounds.

Returns:
vcEdgeType: Edge type.
getTriangleNormalvcVectorInteger triangleIndexReturns the surface normal of a triangle at a given index in set.
See more
Parameters:
triangleIndex (int): Index for the triangle.

Exceptions:
IndexError: Index out of bounds.

Returns:
vcVector: Normal vector.
mergePointsNoneReal tolerance,
Optional Keyword[onlyBoundaryPoints = Boolean]
Merges points of triangles within a given tolerance that are not connected to one another by adding lines.
See more
Parameters:
tolerance (float): Merge tolerance.
Optional: onlyBoundaryPoints (bool): This argument can be used to only merge points that border one another and that are within the given tolerance.
setCreaseAngleNoneReal creaseAngleSets the angle tolerance for triangle edge shading in which edge angles less than tolerance are rendered as smooth surfaces during light calculations.

Parameters:
creaseAngle (float): New value for the crease angle.
setPointNoneInteger pointIndex,
vcVector point
Sets the position vector of a point at a given index in set.
See more
Parameters:
pointIndex (int): Index for the point.
point (vcVector): Position for the point.

Exceptions:
IndexError: Index out of bounds.
setTextureCoordinateNoneInteger textureCoordinateIndex,
Real u,
Real v
Sets the texture coordinates of a point at a given index in set.
See more
Parameters:
textureCoordinateIndex (int): Index for the coordinate.
u (float): horizontal coordinate.
v (float): vertical coordinate.

Exceptions:
IndexError: Index out of bounds.
setTextureCoordinatesNoneList[Integer] indices,
List[tuple[Real, Real]] textureCoordinates
Sets the texture coordinates of points at a given list of indices in set.
See more
Parameters:
indices (list[int]): List of integer indices
textureCoordinates (list[tuple[float, float]]): List of 2-tuple (float u, float v) coordinates.

Exceptions:
LicenseError: No license for Modeling API.
ValueError: Size for the indices and texture coordinates do not match.
setTriangleNoneInteger triangleIndex,
Integer pointIndex1,
Integer pointIndex2,
Integer pointIndex3
Sets the vertex indices of a triangle at a given index in set.
See more
Parameters:
triangleIndex (int): index of the triangle.
pointIndex1 (int): Vertex index for triangles first vertex.
pointIndex2 (int): Vertex index for triangles second vertex.
pointIndex3 (int): Vertex index for triangles third vertex.

Exceptions:
IndexError: Index out of bounds.
subdivideNoneReal maxEdgeLength,
Optional Keyword[maxTriangles = Integer]
Modifies triangles in set into smaller triangles with edge lengths smaller or equal to a given maxEdgeLength.
See more
A maxTriangles argument can be given to stop subdivision when triangle count reaches a maximum limit.

Parameters:
maxEdgeLength (float): Edge length limit.
Optional: maxTriangles (int): Triangle count limit.
updateNoneNoneUpdates the set and its bound box.

Example: Create Sphere with Triangle Sets

''' vcTriangleSet: Create sphere with triangle sets '''

import vcCore as vc
import vcFeatures as vc_fea
vc_ft = vc_fea.vcFeatureType
import vcGeometry as vc_geo
vc_gst = vc_geo.vcGeometrySetType

app = vc.getApplication()
comp = vc.getComponent()
geometry = comp.findFeature("Geometry")
if not geometry:
  geometry = comp.RootFeature.create(vc_ft.GEOMETRY, "Geometry")

geometry.Geometry.clear()
triangle_set = geometry.Geometry.createGeometrySet(vc_gst.TRIANGLE_SET)
 
radius_vector = vc.vcVector.new(100.0, 0.0, 0.0)
matrix = vc.vcMatrix.new()

for i in range(0,361,15): # Step every 15 degrees around Z (first and last coincident)
  for j in range(90,-91,-15): # Half circle in 12 sections around Y,
    # starting from south pole
    matrix.identity() # always reset the origin before rotate
    matrix.rotateRelZ(i)
    matrix.rotateRelY(j)
    p = matrix * radius_vector       # transform the radius vector with reoriented origin
    triangle_set.addPoint(p)

for i in range(26): # i is the section around Z (12 in each)
  for j in range(12): # is around the rotating y axis
    triangle_set.addTriangle(i*12+j,(i+1)*12+j,(i+1)*12+j+1)
    triangle_set.addTriangle(i*12+j+1,i*12+j,(i+1)*12+j+1)
     
geometry.rebuild()
comp.update() 
app.render()